/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.ufba.lasid.jitclouds.mda;

import br.ufba.lasid.jitclouds.mda.api.IReplicatedVirtualMachineHandler;
import br.ufba.lasid.jitclouds.mda.api.IVirtualMachineHandler;
import br.ufba.lasid.jitclouds.mda.datatypes.ReplicatedXenVMHandler;

/**
 *
 * @author aliriosa
 */
public class MDAAppl {
    public static void main(String[] args) throws Exception{
        IReplicatedVirtualMachineHandler vm = new ReplicatedXenVMHandler();
        //IVirtualMachine vm = rvm; //new XenVirtualMachine();
                
        
        vm.connect("vm1");
        
        System.out.println(
            "[Debug] handling " + vm.getID() + " at " + vm.getLocation()
        );        

        System.out.println("[Debug] Current group view :" + vm.getGroupView());        
        
        int i = -1;
        if(args.length > 0){
            i = Integer.parseInt(args[0]);
        }
        
        switch(i){
            case 0:
                vm.create();
                break;
            case 1:
                vm.destroy();
                break;
            case 2:
                vm.pause();
                break;                
            case 3:
                vm.unpause();
                break;
            case 4:
                vm.checkpoint();
                break;                                
            case 5:
                vm.restore();
                break;                
            case 6:
                vm.restoreAndRun();
                break;                                                
            case 7:
                String status = vm.getStatus();
                System.out.println("vm status ==> " + status);
                break;                                                
                
            case 8:
                boolean ret = vm.isPrimary();
                System.out.println("Primary ==> " + ret);
                break;                                                
            
            case 9:
                vm.sync();
                break;
                
        }
    }
}
